package com.aia.ann.web.json;

import java.util.Map;

import org.apache.log4j.Logger;
import org.apache.struts2.interceptor.SessionAware;

import com.aia.ann.domain.Agent;
import com.aia.ann.service.ChiefService;
import com.cfh.util.Tools;
import com.opensymphony.xwork2.ActionSupport;

public class AnnSendMailJson extends ActionSupport implements SessionAware {
	private static final Logger logger = Logger.getLogger(AnnSendMailJson.class);

	private static final long serialVersionUID = 1L;

	//mmt_email , mmt_words
	
	private Map session;
	private String mmt_email;
	private String mmt_words;
	
	private ChiefService chiefService;

	public void setSession(Map session) {
		this.session = session;
	}

	public Map getSession() {
		return session;
	}


	public void setChiefService(ChiefService chiefService) {
		this.chiefService = chiefService;
	}

	public ChiefService getChiefService() {
		return chiefService;
	}
	

	public void validate() {
		try {
			Agent cust = (Agent) session.get("customer");
			if (cust == null) {
				addActionError("没有登录或会话超时");
				return;
			}
		} catch (Exception e) {
			addActionError("Unknown Error");
			logger.error("Unknown Error", e);
			return;
		}
	}
	

	public String execute() throws Exception {
		try {
			if (logger.isDebugEnabled()) {
				logger.debug("annSendMailJson - start"); //$NON-NLS-1$
			}
			
			chiefService.annSendMailJson(this);
			
			if (logger.isDebugEnabled()) {
				logger.debug("annSendMailJson - end"); //$NON-NLS-1$
			}
			
			return Tools.smartReturn((ActionSupport) this);
		} catch (Exception e) {
			logger.error("Unknown Error:" + e, e);
			throw new RuntimeException(e);
		}
	}

	public void setMmt_email(String mmt_email) {
		this.mmt_email = mmt_email;
	}

	public String getMmt_email() {
		return mmt_email;
	}

	public void setMmt_words(String mmt_words) {
		this.mmt_words = mmt_words;
	}

	public String getMmt_words() {
		return mmt_words;
	}

}
